<?php

namespace app\api\service;

use HuaweiCloud\SDK\Live\V1\Model\DeleteDomainMappingRequest;
use HuaweiCloud\SDK\Live\V1\Model\DeleteDomainRequest;
use HuaweiCloud\SDK\Live\V1\Model\ListLiveStreamsOnlineRequest;
use HuaweiCloud\SDK\Live\V1\Model\LiveDomainModifyReq;
use HuaweiCloud\SDK\Live\V1\Model\ShowDomainRequest;
use HuaweiCloud\SDK\Cdn\V1\Model\CreateDomainRequest;
use HuaweiCloud\SDK\Core\Auth\BasicCredentials;
use HuaweiCloud\SDK\Core\Http\HttpConfig;
use HuaweiCloud\SDK\Core\Exceptions\ConnectionException;
use HuaweiCloud\SDK\Core\Exceptions\RequestTimeoutException;
use HuaweiCloud\SDK\Core\Exceptions\ServiceResponseException;
use HuaweiCloud\SDK\Live\V1\LiveClient;
use HuaweiCloud\SDK\Live\V1\Model\CreateDomainMappingRequest;
use HuaweiCloud\SDK\Live\V1\Model\DomainMapping;
use HuaweiCloud\SDK\Live\V1\Model\LiveDomainCreateReq;
use HuaweiCloud\SDK\Live\V1\Model\UpdateDomainRequest;
use NLP\Jieba\Finalseg;
use NLP\Jieba\Jieba;
use Obs\ObsClient;
use think\Env;
use think\Exception;

// 结巴分词 https://github.com/cyd622/nlp-jieba
class JieBaFenCi
{

    /**
     * 分割语句
     * @param string $str 要分词的字符串
     * @param int $cut_type 分词的模式 1=普通模式,2=全模式,3=默认精确模式,4=搜索引擎模式
     */
    public function cutStatement(string $str,$cut_type = 1){
        Jieba::init();
        Finalseg::init();

        $str = trim($str);
        switch ($cut_type){
            case 2:
                $seg_list = Jieba::cut($str,true);//全模式
                break;
            case 3:
                $seg_list = Jieba::cut($str,false);//默认精确模式
                break;
            case 4:
                $seg_list = Jieba::cutForSearch($str);//搜索引擎模式
                break;
            default:
                $seg_list = Jieba::cut($str);//普通模式
                break;
        }
        return $seg_list;
    }
}
